package work_Experiment_3;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 34255
 * Date: 2024-11-03
 * Time: 17:07
 */
import java.util.InputMismatchException;
import java.util.Scanner;

public class abnormal {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        try {
            System.out.print("请输入第一个数: ");
            double numerator = scanner.nextDouble();

            System.out.print("请输入第二个数 (除数): ");
            double denominator = scanner.nextDouble();

            if (denominator == 0) {
                throw new ArithmeticException("除数不能为零");
            }

            double result = numerator / denominator;
            System.out.println("结果是: " + result);
        } catch (InputMismatchException e) {
            System.out.println("参数输入有误: 请确保输入的是有效的数字。");
        } catch (ArithmeticException e) {
            System.out.println("异常: " + e.getMessage());
        }
    }
}